<?php
require('system-config.php');
require(LYCEUMSRCROOT.'lib/taglib.php');
$site_title = get_settings('site_title');

$myblogs = get_userblogs();
arrayify($myblogs);

// ===========================================================================
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
	"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>
	<title><?php echo $site_title ?>: Lyceum System Settings</title>

	<link rel="stylesheet" href="<?php echo LURL ?>/wp-admin/wp-admin.css" type="text/css" />
	<link rel="stylesheet" href="<?php echo LURL ?>/system-admin/lyceum.css" type="text/css" />

	<meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php echo get_settings('blog_charset'); ?>" />
</head>


<body>

<div id="PageWrapper" class="AdminMain">

<?php require(ABSPATH . '/system-admin/lyceum-header.php'); ?>

	<hr />

	<!-- BEGIN: body -->
	<div id="BodyWrapper">

		<!-- BEGIN: main column -->
		<div id="MainColumn">

			<!-- BEGIN: main nav -->
			<ul id="MainNav">
				<li class="Selected"><span><a href="settings.php">System Settings</a></span></li>
				<li><span><a href="blog-management.php">Blogs</a></span></li>
				<li><span><a href="user-management.php">Users</a></span></li>
				<li><span><a href="systemplugins.php">Plugins</a></span></li>
				<li><span><a href="rewriterules.php">Apache Rewrite Rules</a></span></li>
			</ul>
			<div class="ClearFix TabBorder"><!-- do not remove --></div>
			<!-- END: main nav -->

			<div class="wrap">
				<h2>Lyceum Config</h2>

				<form method="post" action="setoption.php" class="lyceum_form">
					<?php echo tokeninput('setoption.php', 'site_title')?>
					<input type="hidden" name="option" value="site_title" />

					<table class="FormTable">
						<col width="20%" />
						<col width="80%" />

						<tbody>
							<tr>
								<th scope="row"><label for="site_title">Site Title</label></th>
								<td>
									<input type="text" name="value" id="site_title" maxlength="100" value="<?php echo  get_option('site_title') ?>" class="TextInput" />
									<input type="submit" value="Submit" name="submit" class="Button" />
								</td>
							</tr>
						</tbody>
					</table>
				</form>

				<form method="post" action="setoption.php" class="lyceum_form">
					<?php echo tokeninput('setoption.php', 'system_admin_email')?>
					<input type="hidden" name="option" value="system_admin_email" />

					<table class="FormTable">
						<col width="20%" />
						<col width="80%" />

						<tbody>
							<tr>
								<th scope="row"><label for="system_admin_email">System Admin Email</label></th>
								<td>
									<input type="text" name="value" id="system_admin_email" maxlength="100" value="<?php echo  get_option('system_admin_email') ?>" class="TextInput" />
									<input type="submit" value="Submit" name="submit" class="Button" />
								</td>
							</tr>
						</tbody>
					</table>
				</form>

				<form method="post" action="setoption.php" class="lyceum_form">
					<?php echo tokeninput('setoption.php', 'wp-content_file_path')?>
					<input type="hidden" name="option" value="wp-content_file_path" />

					<table class="FormTable">
						<col width="20%" />
						<col width="80%" />

						<tbody>
							<tr>
								<th scope="row"><label for="wp_content_path">wp-content_file_path</label></th>
								<td>
									<input type="text" name="value" id="wp_content_path" maxlength="200" value="<?php echo  get_option('wp-content_file_path') ?>" class="TextInput" />
									<input type="submit" value="Submit" name="submit" class="Button" />
									<div class="HelpText">The file path where individual blog uploads and cache are kept.</div>
								</td>
							</tr>
						</tbody>
					</table>
				</form>

				<form method="post" action="setoption.php" class="lyceum_form">
					<?php echo tokeninput('setoption.php', 'fileupload_base_url')?>
					<input type="hidden" name="option" value="fileupload_base_url" />

					<table class="FormTable">
						<col width="20%" />
						<col width="80%" />

						<tbody>
							<tr>
								<th scope="row"><label for="fileupload_base_url">File upload base url</label></th>
								<td>
									<input type="text" name="value" id="fileupload_base_url" maxlength="100" value="<?php echo  get_option('fileupload_base_url') ?>" class="TextInput" />
									<input type="submit" value="Submit" name="submit" class="Button" />
									<div class="HelpText">This needs to work with wp-content_file_path above.</div>
								</td>
							</tr>
						</tbody>
					</table>
				</form>

				<form method="post" action="setoption.php" class="lyceum_form">
					<?php echo tokeninput('setoption.php', 'blog_charset')?>
					<input type="hidden" name="option" value="blog_charset" />

					<table class="FormTable">
						<col width="20%" />
						<col width="80%" />

						<tbody>
							<tr>
								<th scope="row"><label for="blog_charset">System character encoding</label></th>
								<td>
									<input type="text" name="value" id="blog_charset" maxlength="100" value="<?php echo  get_option('blog_charset') ?>" class="TextInput" />
									<input type="submit" value="Submit" name="submit" class="Button" />
								</td>
							</tr>
						</tbody>
					</table>
				</form>

				<form method="post" action="setoption.php" class="lyceum_form">
					<?php echo tokeninput('setoption.php', 'html_type')?>
					<input type="hidden" name="option" value="html_type" />

					<table class="FormTable">
						<col width="20%" />
						<col width="80%" />

						<tbody>
							<tr>
								<th scope="row"><label for="html_type">System HTML type</label></th>
								<td>
									<input type="text" name="value" id="html_type" maxlength="100" value="<?php echo  get_option('html_type') ?>" class="TextInput" />
									<input type="submit" value="Submit" name="submit" class="Button" />
								</td>
							</tr>
						</tbody>
					</table>
				</form>

				<form method="post" action="setoption.php" class="lyceum_form">
					<?php echo tokeninput('setoption.php', 'email_structure')?>
					<input type="hidden" name="option" value="email_structure" />

					<table class="FormTable">
						<col width="20%" />
						<col width="80%" />

						<tbody>
							<tr>
								<th scope="row"><label for="email_structure">email regex</label></th>
								<td>
									<input type="text" name="value" id="email_structure" maxlength="100" value="<?php echo  get_option('email_structure') ?>" class="TextInput" />
									<input type="submit" value="Submit" name="submit" class="Button" />
									<div class="HelpText">Regular expression against which new email addresses must match (example: <strong>/.*@example\.tld/</strong>)</div>
								</td>
							</tr>
						</tbody>
					</table>
				</form>

				<form method="post" action="setoption.php" class="lyceum_form">
					<?php echo tokeninput('setoption.php', 'email_structure_error_message')?>
					<input type="hidden" name="option" value="email_structure_error_message" />

					<table class="FormTable">
						<col width="20%" />
						<col width="80%" />

						<tbody>
							<tr>
								<th scope="row"><label for="email_regex_error">email regex error</label></th>
								<td>
									<input type="text" name="value" id="email_regex_error" maxlength="100" value="<?php echo  get_option('email_structure_error_message') ?>" class="TextInput" />
									<input type="submit" value="Submit" name="submit" class="Button" />
									<div class="HelpText">(example: <strong>You must have a example.tld email address in order to make an account.</strong>)</div>
								</td>
							</tr>
						</tbody>
					</table>
				</form>

				<form method="post" action="setoption.php" class="lyceum_form">
					<?php echo tokeninput('setoption.php', 'slug_blacklist')?>
					<input type="hidden" name="option" value="slug_blacklist" />

					<table class="FormTable">
						<col width="20%" />
						<col width="80%" />

						<tbody>
							<tr>
								<th scope="row"><label for="slug_blacklist">Unregisterable Slugs</label></th>
								<td>
									<textarea name="value" cols="60" rows="5" id="slug_blacklist" class="TextArea"><?php echo  get_option('slug_blacklist') ?></textarea>
									<input type="submit" value="Submit" name="submit" class="Button" />
									<div class="HelpText">Comma-separated with no spaces.</div>
								</td>
							</tr>
						</tbody>
					</table>
				</form>

				<form method="post" action="setoption.php" class="lyceum_form">
					<?php echo tokeninput('setoption.php', 'username_blacklist')?>
					<input type="hidden" name="option" value="username_blacklist" />

					<table class="FormTable">
						<col width="20%" />
						<col width="80%" />

						<tbody>
							<tr>
								<th scope="row"><label for="username_blacklist">Unregisterable Usernames</label></th>
								<td>
									<textarea name="value" cols="60" rows="5" id="username_blacklist" class="TextArea"><?php echo  get_option('username_blacklist') ?></textarea>
									<input type="submit" value="Submit" name="submit" class="Button" />
									<div class="HelpText">Comma-separated with no spaces.</div>
								</td>
							</tr>
						</tbody>
					</table>
				</form>

				<form method="post" action="setoption.php" class="lyceum_form">
					<?php echo tokeninput('setoption.php', 'users_can_register')?>
					<input type="hidden" name="option" value="users_can_register" />

					<table class="FormTable">
						<col width="20%" />
						<col width="80%" />

						<tbody>
							<tr>
								<th scope="row"><span class="Label">Open Registration</span></th>
								<td>
									<ul class="HorizList Inputs">
										<li><input type="radio" name="value" id="open_reg_1" value="1" <?php echo  get_option('users_can_register')?'checked="checked"':"" ?> /> <label for="open_reg_1">Enabled</label></li>
										<li><input type="radio" name="value" id="open_reg_0" value="0" <?php echo  !get_option('users_can_register')?'checked="checked"':"" ?> /> <label for="open_reg_0">Disabled</label></li>
									</ul>
									<input type="submit" value="Submit" name="submit" class="Button" />
									<div class="HelpText">Allow users to register themselves for an account and blog. (Above regular expression still applies.)</div>
								</td>
							</tr>
						</tbody>
					</table>
				</form>

				<form method="post" action="setoption.php" class="lyceum_form">
					<?php echo tokeninput('setoption.php', 'presentation_tab')?>
					<input type="hidden" name="option" value="presentation_tab" />

					<table class="FormTable">
						<col width="20%" />
						<col width="80%" />

						<tbody>
							<tr>
								<th scope="row"><span class="Label">User Customization</span></th>
								<td>
									<ul class="HorizList Inputs">
										<li><input type="radio" name="value" id="presentation_tab_1" value="1" <?php echo  get_option('presentation_tab')?'checked="checked"':"" ?> /> <label for="presentation_tab_1">Enabled</label></li>
										<li><input type="radio" name="value" id="presentation_tab_0" value="0" <?php echo  !get_option('presentation_tab')?'checked="checked"':"" ?> /> <label for="presentation_tab_0">Disabled</label></li>
									</ul>
									<input type="submit" value="Submit" name="submit" class="Button" />
									<div class="HelpText">Allow users to change their blog's theme and adjust its settings.</div>
								</td>
							</tr>
						</tbody>
					</table>
				</form>

				<form method="post" action="setoption.php" class="lyceum_form">
					<?php echo tokeninput('setoption.php', 'import_allowed')?>
					<input type="hidden" name="option" value="import_allowed" />

					<table class="FormTable">
						<col width="20%" />
						<col width="80%" />

						<tbody>
							<tr>
								<th scope="row"><span class="Label">Import Scripts</span></th>
								<td>
									<ul class="HorizList Inputs">
										<li><input type="radio" name="value" id="import_allowed_1" value="1" <?php echo  get_option('import_allowed')?'checked="checked"':"" ?> /> <label for="import_allowed_1">Enabled</label></li>
										<li><input type="radio" name="value" id="import_allowed_0" value="0" <?php echo  !get_option('import_allowed')?'checked="checked"':"" ?> /> <label for="import_allowed_0">Disabled</label></li>
									</ul>
									<input type="submit" value="Submit" name="submit" class="Button" />
									<div class="HelpText">Allow users to use the import scripts? (These scripts are not yet thoroughly tested and are therefore a potential security vulnerability)</div>
								</td>
							</tr>
						</tbody>
					</table>
				</form>

				<form method="post" action="setoption.php" class="lyceum_form">
					<?php echo tokeninput('setoption.php', 'gzipcompression')?>
					<input type="hidden" name="option" value="gzipcompression" />

					<table class="FormTable">
						<col width="20%" />
						<col width="80%" />

						<tbody>
							<tr>
								<th scope="row"><span class="Label">gzip Compression</span></th>
								<td>
									<ul class="HorizList Inputs">
										<li><input type="radio" name="value" id="gzipcompression_1" value="1" <?php echo  get_option('gzipcompression')?'checked="checked"':"" ?> /> <label for="gzipcompression_1">Enabled</label></li>
										<li><input type="radio" name="value" id="gzipcompression_0" value="0" <?php echo  !get_option('gzipcompression')?'checked="checked"':"" ?> /> <label for="gzipcompression_0">Disabled</label></li>
									</ul>
									<input type="submit" value="Submit" name="submit" class="Button" />
									<div class="HelpText">Compress articles (gzip) if browsers ask for them.</div>
									<div class="Note">This feature has not been tested.</div>
								</td>
							</tr>
						</tbody>
					</table>
				</form>

				<form method="post" action="setoption.php" class="lyceum_form">
					<?php echo tokeninput('setoption.php', 'restrict_admin_ip')?>
					<input type="hidden" name="option" value="restrict_admin_ip" />

					<table class="FormTable">
						<col width="20%" />
						<col width="80%" />

						<tbody>
							<tr>
								<th scope="row"><span class="Label">Restrict Admin IP</span></th>
								<td>
									<ul class="HorizList Inputs">
										<li><input type="radio" name="value" id="restrict_admin_ip_1" value="1" <?php echo  get_option('restrict_admin_ip')?'checked="checked"':"" ?> /> <label for="restrict_admin_ip_1">Enabled</label></li>
										<li><input type="radio" name="value" id="restrict_admin_ip_0" value="0" <?php echo  !get_option('restrict_admin_ip')?'checked="checked"':"" ?> /> <label for="restrict_admin_ip_0">Disabled</label></li>
									</ul>
									<input type="submit" value="Submit" name="submit" class="Button" />
									<div class="HelpText">Restrict IP addresses from which an administrator may log in.</div>
									<div class="Note"><strong>BEFORE YOU TURN THIS ON:</strong> Make sure that your current IP address, <strong><?php echo $_SERVER['REMOTE_ADDR']?></strong>, is in the list below.</div>
								</td>
							</tr>
						</tbody>
					</table>
				</form>

				<form method="post" action="adminip.php" class="lyceum_form">
					<?php echo tokeninput('adminip.php')?>

					<table class="FormTable">
						<col width="20%" />
						<col width="80%" />

						<tbody>
							<tr>
								<th scope="row"><label for="admin_ip">New Admin IP</label></th>
								<td>
									<input type="text" name="ip" id="admin_ip" maxlength="15" class="TextInput" />
									<input type="submit" value="Submit" name="submit" class="Button" />
								</td>
							</tr>

							<tr>
								<th scope="row">Current Admin IPs</th>
								<td>
									<ul>
<?php
$ips = get_admin_ips();
foreach($ips as $ip) {
?>
										<li><?php echo $ip ?></li>
<?php
}
?>
									</ul>
								</td>
							</tr>

						</tbody>
					</table>
				</form>

			</div>

		</div>
		<!-- END: main column -->

	</div>
	<!-- END: body -->

	<hr />

<?php include(ABSPATH . 'wp-admin/admin-footer.php'); ?>

</div>


</body>

</html>
